// EA_K_BPA.cpp: implementation of the CEA_K_BPA class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "../../Include/Swi/EA_K_BPA.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CEA_K_BPA::CEA_K_BPA()
{
	m_chType = 'E';
	m_chSubType = 'A';
	m_chChangeCode = ' ';

	m_dTr = 0;
	m_dKa = 0;
	m_dTa = 0;
	m_dTa1 = 0;
	m_dVrMinMult = 0;
	m_dKe = 0;
	m_dTe = 0;
	m_dSe75Max = 0;
	m_dSeMax = 0;
	m_dEfdMin = 0;
	m_dEfdMax = 0;
	m_dKf = 0;
	m_dTf = 0;
	m_dXl = 0;
	m_dTf1 = 0;

	m_strCardType[0] = 'E';

}

CEA_K_BPA::CEA_K_BPA(CEA_K_BPA &ea_kBPA):CUnit_BPA(ea_kBPA)
{
	m_dTr = ea_kBPA.m_dTr;
	m_dKa = ea_kBPA.m_dKa;
	m_dTa = ea_kBPA.m_dTa;
	m_dTa1 = ea_kBPA.m_dTa1;
	m_dVrMinMult = ea_kBPA.m_dVrMinMult;
	m_dKe = ea_kBPA.m_dKe;
	m_dTe = ea_kBPA.m_dTe;
	m_dSe75Max = ea_kBPA.m_dSe75Max;
	m_dSeMax = ea_kBPA.m_dSeMax;
	m_dEfdMin = ea_kBPA.m_dEfdMin;
	m_dEfdMax = ea_kBPA.m_dEfdMax;
	m_dKf = ea_kBPA.m_dKf;
	m_dTf = ea_kBPA.m_dTf;
	m_dXl = ea_kBPA.m_dXl;
	m_dTf1 = ea_kBPA.m_dTf1;
}

CEA_K_BPA::~CEA_K_BPA()
{

}

bool CEA_K_BPA::FillEx(char *buffer)
{
	bool bResult = CUnit_BPA::FillEx(buffer);

	if (!bResult)
	{
		printf("Error in (CEA_K_BPA::FillEx): no basic information!\n");
		return false;
	}

	if (strlen(buffer)<17)
		return true;

	m_dTr = StrToDouble(&buffer[16],4,3);
	if(EndOfSec(&buffer[16],4))
		return true;

	m_dKa = StrToDouble(&buffer[20],5,2);
	if(EndOfSec(&buffer[20],5))
		return true;

	m_dTa = StrToDouble(&buffer[25],4,2);
	if(EndOfSec(&buffer[25],4))
		return true;

	m_dTa1 = StrToDouble(&buffer[29],4,3);
	if(EndOfSec(&buffer[29],4))
		return true;

	m_dVrMinMult = StrToDouble(&buffer[33],4,2);
	if(EndOfSec(&buffer[33],4))
		return true;

	m_dKe = StrToDouble(&buffer[37],4,3);
	if(EndOfSec(&buffer[37],4))
		return true;

	m_dTe = StrToDouble(&buffer[41],4,3);
	if(EndOfSec(&buffer[41],4))
		return true;

	m_dSe75Max = StrToDouble(&buffer[45],4,3);
	if(EndOfSec(&buffer[45],4))
		return true;

	m_dSeMax = StrToDouble(&buffer[49],4,3);
	if(EndOfSec(&buffer[49],4))
		return true;

	m_dEfdMin = StrToDouble(&buffer[53],5,3);
	if(EndOfSec(&buffer[53],5))
		return true;

	m_dEfdMax = StrToDouble(&buffer[58],4,3);
	if(EndOfSec(&buffer[58],4))
		return true;

	m_dKf = StrToDouble(&buffer[62],4,3);
	if(EndOfSec(&buffer[62],4))
		return true;

	m_dTf = StrToDouble(&buffer[66],4,3);
	if(EndOfSec(&buffer[66],4))
		return true;

	m_dXl = StrToDouble(&buffer[70],5,4);
	if(EndOfSec(&buffer[70],5))
		return true;

	m_dTf1 = StrToDouble(&buffer[75],5,4);
	if(EndOfSec(&buffer[75],5))
		return true;

	return true;
}

bool CEA_K_BPA::UpdateEx(char *buffer)
{
	bool bResult = CUnit_BPA::UpdateEx(buffer);

	if (!bResult)
	{
		printf("Error in (CEA_K_BPA::UpdateEx): impossible!\n");
		return false;
	}

	DoubleToStr(m_dTr,&buffer[16],4,3);
	DoubleToStr(m_dKa,&buffer[20],5,2);
	DoubleToStr(m_dTa,&buffer[25],4,2);
	DoubleToStr(m_dTa1,&buffer[29],4,3);
	DoubleToStr(m_dVrMinMult,&buffer[33],4,2);
	DoubleToStr(m_dKe,&buffer[37],4,3);
	DoubleToStr(m_dTe,&buffer[41],4,3);
	DoubleToStr(m_dSe75Max,&buffer[45],4,3);
	DoubleToStr(m_dSeMax,&buffer[49],4,3);
	DoubleToStr(m_dEfdMin,&buffer[53],5,3);
	DoubleToStr(m_dEfdMax,&buffer[58],4,3);
	DoubleToStr(m_dKf,&buffer[62],4,3);
	DoubleToStr(m_dTf,&buffer[66],4,3);
	DoubleToStr(m_dXl,&buffer[70],5,4);
	DoubleToStr(m_dTf1,&buffer[75],5,4);

	return true;
}